package com.liuzh.deviceinfo.widget;

import android.annotation.SuppressLint;
import android.appwidget.AppWidgetProvider;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import c.h.a.m0.h;

public class CommonWidget extends AppWidgetProvider {
    public static int a;
    public static int b;
    public static BroadcastReceiver c = new a();
    public static int d;
    public static int e;

    public static class a extends BroadcastReceiver {
        @SuppressLint({"SetTextI18n"})
        public void onReceive(Context context, Intent intent) {
            if (intent != null) {
                CommonWidget.a = intent.getIntExtra("level", 0);
                CommonWidget.b = intent.getIntExtra("status", -1);
                CommonWidget.d = intent.getIntExtra("voltage", 0);
                CommonWidget.e = intent.getIntExtra("temperature", 0) / 10;
                h.y(CommonWidget.class);
            }
        }
    }

    public void onDisabled(Context context) {
    }

    public void onEnabled(Context context) {
    }

    /* JADX WARNING: Removed duplicated region for block: B:14:0x018c  */
    /* JADX WARNING: Removed duplicated region for block: B:13:0x018a  */
    public void onUpdate(android.content.Context r19, android.appwidget.AppWidgetManager r20, int[] r21) {
        /*
        r18 = this;
        r0 = r19;
        r1 = r21;
        r2 = r1.length;
        r3 = 0;
        r4 = 0;
    L_0x0007:
        if (r4 >= r2) goto L_0x0199;
    L_0x0009:
        r5 = r1[r4];
        r6 = new android.widget.RemoteViews;
        r7 = r19.getPackageName();
        r8 = 2131493147; // 0x7f0c011b float:1.8609766E38 double:1.0530975383E-314;
        r6.<init>(r7, r8);
        r7 = r19.getApplicationContext();
        r8 = new android.app.ActivityManager$MemoryInfo;	 Catch:{ Exception -> 0x0042 }
        r8.<init>();	 Catch:{ Exception -> 0x0042 }
        r9 = "activity";
        r7 = r7.getSystemService(r9);	 Catch:{ Exception -> 0x0042 }
        r7 = (android.app.ActivityManager) r7;	 Catch:{ Exception -> 0x0042 }
        if (r7 != 0) goto L_0x002b;
    L_0x002a:
        goto L_0x0042;
    L_0x002b:
        r7.getMemoryInfo(r8);	 Catch:{ Exception -> 0x0042 }
        r9 = r8.availMem;	 Catch:{ Exception -> 0x0042 }
        r11 = 1024; // 0x400 float:1.435E-42 double:5.06E-321;
        r9 = r9 / r11;
        r9 = r9 / r11;
        r9 = (double) r9;	 Catch:{ Exception -> 0x0042 }
        r7 = r8.totalMem;	 Catch:{ Exception -> 0x0042 }
        r7 = r7 / r11;
        r7 = r7 / r11;
        r7 = (double) r7;
        r9 = r7 - r9;
        r11 = 4636737291354636288; // 0x4059000000000000 float:0.0 double:100.0;
        r11 = r11 * r9;
        r11 = r11 / r7;
        goto L_0x0048;
    L_0x0042:
        r7 = 0;
        r11 = 0;
        r9 = 0;
    L_0x0048:
        r13 = java.util.Locale.getDefault();
        r14 = 1;
        r15 = new java.lang.Object[r14];
        r16 = 4652218415073722368; // 0x4090000000000000 float:0.0 double:1024.0;
        r7 = r7 / r16;
        r7 = java.lang.Double.valueOf(r7);
        r15[r3] = r7;
        r7 = "%.2fG";
        r8 = java.lang.String.format(r13, r7, r15);
        r13 = java.util.Locale.getDefault();
        r15 = new java.lang.Object[r14];
        r9 = r9 / r16;
        r9 = java.lang.Double.valueOf(r9);
        r15[r3] = r9;
        r9 = java.lang.String.format(r13, r7, r15);
        r10 = new java.lang.StringBuilder;
        r10.<init>();
        r11 = (int) r11;
        r10.append(r11);
        r12 = "%";
        r10.append(r12);
        r10 = r10.toString();
        r13 = 2131296819; // 0x7f090233 float:1.8211565E38 double:1.0530005394E-314;
        r6.setTextViewText(r13, r10);
        r10 = 2131296821; // 0x7f090235 float:1.821157E38 double:1.0530005403E-314;
        r13 = new java.lang.StringBuilder;
        r13.<init>();
        r15 = "/";
        r8 = c.b.a.a.a.e(r13, r9, r15, r8);
        r6.setTextViewText(r10, r8);
        r8 = 1117782016; // 0x42a00000 float:80.0 double:5.522576936E-315;
        r9 = r19.getResources();
        r9 = r9.getDisplayMetrics();
        r8 = c.h.a.m0.h.t(r8, r9);
        r9 = android.graphics.Bitmap.Config.ARGB_8888;
        r8 = android.graphics.Bitmap.createBitmap(r8, r8, r9);
        com.liuzh.deviceinfo.widget.RamWidget.b(r0, r8, r11);
        r9 = 2131296815; // 0x7f09022f float:1.8211557E38 double:1.0530005374E-314;
        r6.setImageViewBitmap(r9, r8);
        r8 = new c.h.a.d0.d;
        r8.m1955init(r0);
        r8.c();
        r9 = java.util.Locale.getDefault();
        r10 = new java.lang.Object[r14];
        r14 = r8.b;
        r13 = java.lang.Double.valueOf(r14);
        r10[r3] = r13;
        r9 = java.lang.String.format(r9, r7, r10);
        r10 = java.util.Locale.getDefault();
        r11 = 1;
        r13 = new java.lang.Object[r11];
        r14 = r8.d;
        r14 = java.lang.Double.valueOf(r14);
        r13[r3] = r14;
        r7 = java.lang.String.format(r10, r7, r13);
        r10 = 2131297004; // 0x7f0902ec float:1.821194E38 double:1.053000631E-314;
        r13 = new java.lang.StringBuilder;
        r13.<init>();
        r13.append(r7);
        r7 = " / ";
        r13.append(r7);
        r13.append(r9);
        r7 = r13.toString();
        r6.setTextViewText(r10, r7);
        r7 = new java.lang.StringBuilder;
        r7.<init>();
        r9 = r8.e;
        r9 = (int) r9;
        r7.append(r9);
        r7.append(r12);
        r7 = r7.toString();
        r9 = 2131297005; // 0x7f0902ed float:1.8211943E38 double:1.0530006313E-314;
        r6.setTextViewText(r9, r7);
        r7 = 2131297006; // 0x7f0902ee float:1.8211945E38 double:1.0530006317E-314;
        r8 = r8.e;
        r8 = (int) r8;
        r9 = 100;
        r6.setProgressBar(r7, r9, r8, r3);
        r7 = 2131296388; // 0x7f090084 float:1.8210691E38 double:1.0530003264E-314;
        r8 = new java.lang.StringBuilder;
        r8.<init>();
        r10 = a;
        r8.append(r10);
        r8.append(r12);
        r8 = r8.toString();
        r6.setTextViewText(r7, r8);
        r7 = 2131296390; // 0x7f090086 float:1.8210695E38 double:1.0530003274E-314;
        r8 = new java.lang.StringBuilder;
        r8.<init>();
        r10 = 2131689626; // 0x7f0f009a float:1.9008273E38 double:1.053194612E-314;
        r12 = " (";
        c.b.a.a.a.n(r0, r10, r8, r12);
        r10 = b;
        r10 = c.h.a.m0.k.i(r10, r0);
        r8.append(r10);
        r10 = ")";
        r8.append(r10);
        r8 = r8.toString();
        r6.setTextViewText(r7, r8);
        r7 = 2131296387; // 0x7f090083 float:1.821069E38 double:1.053000326E-314;
        r8 = new java.lang.StringBuilder;
        r8.<init>();
        r10 = d;
        r8.append(r10);
        r10 = "mV / ";
        r8.append(r10);
        r10 = e;
        r8.append(r10);
        r10 = "℃";
        r8.append(r10);
        r8 = r8.toString();
        r6.setTextViewText(r7, r8);
        r7 = 2131296389; // 0x7f090085 float:1.8210693E38 double:1.053000327E-314;
        r8 = a;
        r10 = b;
        r12 = 2;
        if (r10 != r12) goto L_0x018c;
    L_0x018a:
        r14 = 1;
        goto L_0x018d;
    L_0x018c:
        r14 = 0;
    L_0x018d:
        r6.setProgressBar(r7, r9, r8, r14);
        r7 = r20;
        r7.updateAppWidget(r5, r6);	 Catch:{ Exception -> 0x0195 }
    L_0x0195:
        r4 = r4 + 1;
        goto L_0x0007;
    L_0x0199:
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.liuzh.deviceinfo.widget.CommonWidget.onUpdate(android.content.Context, android.appwidget.AppWidgetManager, int[]):void");
    }
}
